﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BillingSystem
{
    public partial class FormEditDirection : Form
    {
        private BindingSource directionsBindingSource = null;

        public FormEditDirection()
        {
            InitializeComponent();
        }

        public bool Show(BindingSource dir)
        {
            DataRowView drv = (DataRowView)dir.Current;

            if (drv.IsNew)
            {
                drv["DIRECTION_ID"] = 0;
                drv["PREFIX"] = 0;
                drv["NAME"] = "";
                this.Text = "Добавление нового направления:";
            }
            else
            {
                this.Text = "Редактирование информации о направлении:";
            }

            this.txtBoxName.DataBindings.Add("Text", drv, "NAME", false,
                DataSourceUpdateMode.OnValidation);
            this.txtBoxPrefix.DataBindings.Add("Text", drv, "PREFIX", false,
                DataSourceUpdateMode.OnValidation, null, "NO");

            if (this.ShowDialog() == DialogResult.OK)
            {
                if (txtBoxName.Text == null || txtBoxPrefix.Text == null)
                {
                    drv.CancelEdit();
                    return false;
                }
                drv.EndEdit();
                return true;
            }
            else
            {
                drv.CancelEdit();
                return false;
            }
        }

        //private void Set
    }
}